<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function findall(a, n) {
            for (var i = 0; i < a.length; i++) {
                if (a[i] == n) {
                    document.write(i + ' .');
                }
            }
        }

        function count(a, n) {
            var c = 0;
            for (var i = 0; i < a.length; i++) {
                if (a[i] == n) {
                    c++;
                }
            }
            document.write('<br>' + c + '<br>');
        }
        var number = prompt("输入查找元素");
        var list = new Array('a', 'c', 'b', 'd', 'a', 'c', 'b', 'b');
        findall(list, number);
        count(list, number);
    </script>
</body>

</html>